package com.lecture.springlecture.controller;

import com.lecture.springlecture.socket.WebsocketEndpoint;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class WebsocketController {

    @Autowired
    private WebsocketEndpoint websocketEndpoint;

    /**
     * 服务端发消息给客户端
     * @param message 消息
     */
    @PostMapping("/send2client")
    public void send2Client(String message){
//        wsServer.sendMessageToAll("this is a test for server to client");
        websocketEndpoint.sendMessageToAll(message);
    }
}
